<!DOCTYPE html>
<html>
<head>
<title>商家登记3/4</title>
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="format-detection" content="telephone=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" href="assets/css/amazeui.min.css" />
<script src="assets/js/jquery.min.js" type="text/javascript"></script>
<script src="assets/js/amazeui.min.js" type="text/javascript"></script>
<script src="js/main.js" type="text/javascript"></script>
<script src="js/md5.js" type="text/javascript"></script>
<style type="text/css">
style.header {
	text-align: center;
}

 #vld-tooltip {
    position: absolute;
    z-index: 1000;
    padding: 5px 10px;
    background: #F37B1D;
    min-width: 150px;
    color: #fff;
    transition: all 0.15s;
    box-shadow: 0 0 5px rgba(0,0,0,.15);
    display: none;
  }

  #vld-tooltip:before {
    position: absolute;
    top: -8px;
    left: 50%;
    width: 0;
    height: 0;
    margin-left: -8px;
    content: "";
    border-width: 0 8px 8px;
    border-color: transparent transparent #F37B1D;
    border-style: none inset solid;
  }
</style>
<script type="text/javascript">
	$(function() {
		getBankList();
		toEditForm();
		doFormValidate('form');
	});
	function toEditForm(){
		var merchant=getSessionValue('mdetail');
		console.log(merchant);
		if(!merchant){
			return;
		}
		merchant=JSON.parse(merchant);	
		if(merchant){
			 $("#settlementdays").val(merchant.settlementdays);
			 $("#settlebankid").val(merchant.settlebankid);
			 $("#settlecard").val(merchant.settlecard);
			 $("#settleusername").val(merchant.settleusername);
			 if(merchant.isservice=='1'){
				 $("#isservice").prop('checked',true);
			 }
			 if(merchant.isfastpaint=='1'){
				 $("#isfastpaint").prop('checked',true);
			 }
			 if(merchant.istakecar=='1'){
				 $("#istakecar").prop('checked',true);
			 }	 
			
		}
	}
	function getBankList() {
		var bankList = baseLoad('getBankList.action', 'bankList');
		if (bankList) {
			var bList = JSON.parse(bankList);
			$.each(bList, function(key, value) {
				$("#settlebankid").append(
						"<option value='"+value.bankid+"'>" + value.bankname
								+ "</option>");
			});
		}
	}
	function doSubmit(type){
		if($('form').validator('isFormValid')){
	
			saveToNext(type);
			
		}
	}
	function saveToNext(type) {
		popLoading();
		var reqData = new RequestData('register3.action');
		var merchantid = getSessionValue("merchantid");
		if (merchantid) {
			reqData.merchantid = merchantid;
		} else {
			reqData.merchantid = "";
		}
		reqData.settlementdays = $("#settlementdays").val();
		reqData.settlebankid = $("#settlebankid").val();
		reqData.settlebankname = $("#settlebankid").find("option:selected")
				.text();
		reqData.settlecard = $("#settlecard").val();
		reqData.settleusername = $("#settleusername").val();
		reqData.isservice = defualtCheckValue('isservice');//$("#isservice").val();
		reqData.isfastpaint = defualtCheckValue('isfastpaint');//$("#isfastpaint").val();
		reqData.istakecar = defualtCheckValue('istakecar');//$("#istakecar").val();
		var jsonstr = JSON.stringify(reqData);
		$.ajax({
			cache : false,
			type : "POST",
			crossDomain : true,
			url : testUrl,
			data : jsonstr, //你的formid
			async : false,
			error : function(request) {
				closeLoading();
				alert("Connection error");
			},
			success : function(data) {
				var dataObj = eval("(" + data + ")");
				if (dataObj.ret == 1) {
					var jsonObj = JSON.stringify(dataObj.rows);			
					window.sessionStorage.setItem("register3", jsonstr);	
					if(type=='snext'){
						location.href = "mregister4.html";
					}else{	
						popAlert('保存成功!');
					}
				}else{
					popAlert(dataObj.msg);
				}
				closeLoading();
			}
		});
	}
	function defualtCheckValue(id) {
		var obj = $('#' + id);
		var value = 0;
		if (obj.prop('checked')) {
			value = 1;
		}
		return value;
	}
	function getAgreement(type) {
		var agreement = baseLoad('getAgreement.action', 'agreement');
		if (agreement) {
			var agreemt = JSON.parse(agreement);
			if (agreemt) {
				if (type == 'agree') {
					Popup('合作协议',agreemt.agreement);
				} else if (type == 'terms') {
					Popup('售后条款',agreemt.terms);
				}

			}
		}

	}
</script>
</head>

<body>
	<header data-am-widget="header" class="am-header am-header-default am-header-fixed">
		<div class="am-header-left am-header-nav">
			<a href="javascript: void(0)"  onclick="javascript:history.back()"> <i
				class="am-header-icon am-icon-chevron-left"></i>
			</a>
		</div>
		<h1 class="am-header-title">
			<a href="#title-link" class=""> 车夫登记3/4 </a>
		</h1>

	</header>
	<div class="am-g" id="mregister3">
		<form class="am-form am-form-horizontal">
			<fieldset>
				<div class="am-form-group">
					<div class="am-u-sm-3">
						<label for="settlementdays" style="margin-top: 0.8em">结算日</label>
					</div>
					<div class="am-u-sm-9">
						<input type="number" class="am-form-field" name="settlementdays" data-foolish-msg="请填写结算日"
							id="settlementdays" required placeholder="天">
					</div>
				</div>
				<div class="am-form-group">
					<div class="am-u-sm-3">
						<label for="settlebankid" style="margin-top: 0.8em">结算银行</label>
					</div>
					<div class="am-u-sm-9">
						<select  name="settlebankid"  id="settlebankid" required data-foolish-msg="请选择结算银行"></select>
					</div>
				</div>
				<div class="am-form-group">
					<div class="am-u-sm-3">
						<label for="settlecard" style="margin-top: 0.8em">结算账户</label>
					</div>
					<div class="am-u-sm-9">
						<input type="number" class="am-form-field" name="settlecard" 
							id="settlecard" data-foolish-msg="请填写结算账户" placeholder="">
					</div>
				</div>
				<div class="am-form-group">
					<div class="am-u-sm-3">
						<label for="settleusername" style="margin-top: 0.8em">账户名</label>
					</div>
					<div class="am-u-sm-9">
						<input type="text" class="am-form-field" name="settleusername"
							id="settleusername" required placeholder="" data-foolish-msg="请填写账户名">
					</div>
				</div>
				<div>
					<div class="am-form-group">
						<div class="am-u-sm-12 am-u-sm-centered">							
								<input type="checkbox" name="isservice" data-theme="d" value="1"
									id="isservice" /> <label for="isservice">无忧售后</label> <input
									type="checkbox" name="isfastpaint" data-theme="d" value="1"
									id="isfastpaint" /> <label for="isfastpaint">24小时快喷</label> <input
									type="checkbox" name="istakecar" data-theme="d" value="1"
									id="istakecar" /> <label for="istakecar">免费送车</label>
							
						</div>
					</div>
				</div>
				<div class="am-form-group">
					<div class="am-u-sm-8 am-u-sm-centered">
						<button type="button" class="am-btn am-btn-primary am-btn-block"
							onclick="getAgreement('agree')">显示合作协议</button>
					</div>
				</div>
				<div class="am-form-group">
					<div class="am-u-sm-8 am-u-sm-centered">
						<button type="button" class="am-btn am-btn-primary am-btn-block"
							onclick="getAgreement('terms')">显示售后条款</button>
					</div>
				</div>
			</fieldset>
		</form>
		<div class="am-g">
			<div class="am-u-sm-9 am-u-sm-centered">
				<a href="#" class="am-btn am-btn-secondary am-btn-block"
					onclick="doSubmit('snext')">确认无误,进入下一步</a>
			</div>
			<div class="am-u-sm-9 am-u-sm-centered" style="margin-top: 0.5em">
				<a href="#" class="am-btn am-btn-secondary am-btn-block" onclick="doSubmit('save')">暂时保存</a>
			</div>
		</div>
	</div>
</body>
</html>
